<template>
  <div class="common-gallery" @click="handleGalleryClick">
    <div class="wrapper">
      <swiper :options="swiperOptions">
        <swiper-slide v-for="(img, index) in imgList" :key="index">
          <img class="gallery-img" :src="img">
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CommonGallery',
  props: {
    imgList: Array
  },
  data() {
    return {
      swiperOptions: {
        pagination: {
          el: '.swiper-pagination',
          type: 'fraction'
        },
        observer: true,
        observeParents:true
      }
    }
  },
  methods: {
    handleGalleryClick() {
      this.$emit('close');
    }
  }
}
</script>

<style lang="stylus" scoped>
.common-gallery
  position fixed
  top 0
  left 0
  right 0
  bottom 0
  z-index 99
  display flex
  flex-direction column
  justify-content center
  background #000
  .wrapper
    height 100%
    .swiper-container 
      height 100%
      .swiper-slide
        display flex
        align-items center
        .gallery-img
          width 100%
      .swiper-pagination
        color #fff
</style>